// formRules.ts
import { computed } from 'vue'
import type { Rule } from 'ant-design-vue/es/form'

/**
 * 获取角色表单验证规则
 * @returns 表单验证规则对象
 */
export const useRoleFormRules = () => {
  const { t } = useI18n()
  
  return computed<Record<string, Rule[]>>(() => ({
    roleName: [
      { required: true, message: t('role.nameRequired'), trigger: 'blur' },
      { min: 2, max: 50, message: t('role.nameLength'), trigger: 'blur' }
    ],
    roleCode: [
      { required: true, message: t('role.codeRequired'), trigger: 'blur' },
      { min: 2, max: 100, message: t('role.codeLength'), trigger: 'blur' }
    ],
    roleSort: [
      { required: true, message: t('role.sortRequired'), trigger: 'blur' },
      { type: 'number', message: t('role.sortNumber'), trigger: 'blur' }
    ]
  }))
} 